package com.ymatou.iapi.settlement.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.settlement.parameter.OrderSettlementReq;
import com.ymatou.iapi.settlement.service.GenerateInvoicesOnOrderReceivedCall;
import com.ymatou.iapi.settlement.service.PredictCommissionCall;
import com.ymatou.iapi.settlement.service.SettlementService;
import com.ymatou.iapi.trading.operate.parameter.ActivityVo;
import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.OrderGroupVo;
import com.ymatou.iapi.trading.operate.parameter.OrderInfoPo;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.SellerCouponVo;
import com.ymatou.iapi.trading.operate.parameter.YmatouCouponVo;
import com.ymatou.iapi.trading.operate.parameter.enums.ActivityPromotionTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.AppTerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.OrderTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PriceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.ProductRefundChannelEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SalesTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.SellerCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.YmatouCouponApplianceTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.req.ApplySalesRefundRequestBean;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.service.PlaceOrderCall;
import com.ymatou.operate.trading.api.service.ApplySalesRefundRequestCall;
import com.ymt.base.YmatouEasyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductCallService;
import com.ymttest.business.service.UserCallService;
import com.ymttest.database.model.YmtCommissionDetail;
import com.ymttest.database.model.YmtSettlementInvoice;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtCommissionDetailWapper;
import com.ymttest.database.sqlwapper.YmtSettlementInvoiceWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 支付后生成预估结算佣金接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_PredictCommission {

	private static OrderSettlementReq generateinvoicesonorderreceivedBean;
	private static PredictCommissionCall predictCommissionCall;
	private static GenerateInvoicesOnOrderReceivedCall generateinvoicesonorderreceivedCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("确认收货时生成结算单接口");
	}

	@Before
	public void caseUp() {

		generateinvoicesonorderreceivedBean = new OrderSettlementReq();
		predictCommissionCall = new PredictCommissionCall();
		generateinvoicesonorderreceivedCall = new GenerateInvoicesOnOrderReceivedCall();

	}
	@AfterClass
	public static void tearDown() {
		Logger.generateResult(generateinvoicesonorderreceivedCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	private void verifyDb() {

		int orderId = generateinvoicesonorderreceivedBean.getOrderId();
		//mq 消息配上后，注释掉该方法
		//	callPredictCommission(orderId);

		try {

			Thread.sleep(5000);

			YmtSettlementInvoiceWapper defaultWapper = new YmtSettlementInvoiceWapper();

			// 佣金
			List<YmtCommissionDetail> ymtCommissionDetailList = new YmtCommissionDetailWapper()
					.selectByOrderId(orderId);

			// 结算佣金
			List<YmtCommissionDetail> ymtSettlemCommissionDetailList = ymtCommissionDetailList
					.stream()
					.filter(commission -> commission.getInvoiceType() == 4)
					.collect(Collectors.toList());

			// 返还佣金
			List<YmtCommissionDetail> ymtBackCommissionDetailList = ymtCommissionDetailList
					.stream()
					.filter(commission -> commission.getInvoiceType() == 6)
					.collect(Collectors.toList());

			// 预估结算佣金
			List<YmtCommissionDetail> predictSettlemCommissionDetailList = ymtCommissionDetailList
					.stream()
					.filter(commission -> commission.getInvoiceType() == 14)
					.collect(Collectors.toList());

			// 预估返还佣金
			List<YmtCommissionDetail> predictBackCommissionDetailList = ymtCommissionDetailList
					.stream()
					.filter(commission -> commission.getInvoiceType() == 15)
					.collect(Collectors.toList());

			for (int i = 0; i < ymtSettlemCommissionDetailList.size(); i++) {

				Logger.comment("验证确认收货后结算收佣明细表的数据与用户付款后预估的收佣结算数据");

				verifyCommissionDetail(ymtSettlemCommissionDetailList.get(i),
						predictSettlemCommissionDetailList.get(i));

			}

			for (int i = 0; i < ymtBackCommissionDetailList.size(); i++) {

				Logger.comment("验证确认收货后结算返佣明细表的数据与用户付款后预估的返佣结算数据");

				verifyCommissionDetail(ymtBackCommissionDetailList.get(i),
						predictBackCommissionDetailList.get(i));
			}

			Map map = new HashMap();

			map.put("orderId", orderId);

			// 查询交易退款结算表
			List<YmtSettlementInvoice> settlementInvoiceList = defaultWapper
					.selectYmtSettlementInvoice(map);

			Logger.verifyEquals(true, settlementInvoiceList.size() >= 2,
					"验证结算表数据");

			Logger.comment("校验确认收货收佣结算与用户付款后预测的收佣结算数据一致");

			verifyYmtSettlementInvoice(
					settlementInvoiceList
							.stream()
							.filter(settlement -> settlement.getBusinessType() == 4)
							.collect(Collectors.toList()).get(0),
					settlementInvoiceList
							.stream()
							.filter(settlement -> settlement.getBusinessType() == 14)
							.collect(Collectors.toList()).get(0));

			Logger.comment("校验确认收货返佣结算与用户付款后预测的返佣结算数据一致");

			verifyYmtSettlementInvoice(
					settlementInvoiceList
							.stream()
							.filter(settlement -> settlement.getBusinessType() == 6)
							.collect(Collectors.toList()).get(0),
					settlementInvoiceList
							.stream()
							.filter(settlement -> settlement.getBusinessType() == 15)
							.collect(Collectors.toList()).get(0));

		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	private void verifyCommissionDetail(YmtCommissionDetail expect,
			YmtCommissionDetail actual) {

		//DataUtil.verify(expect.getId(), actual.getId(), "验证id");
		/*		DataUtil.verify(expect.getOrderInfoId(), actual.getOrderInfoId(),
						"验证orderInfoId");*/
		DataUtil.verify(expect.getOrderId(), actual.getOrderId(), "验证orderId");
		DataUtil.verify(expect.getProductId(), actual.getProductId(),
				"验证productId");
		DataUtil.verify(expect.getCategoryId(), actual.getCategoryId(),
				"验证categoryId");
		DataUtil.verify(expect.getStrategyId(), actual.getStrategyId(),
				"验证strategyId");
		DataUtil.verify(expect.getStrategyLevel(), actual.getStrategyLevel(),
				"验证strategyLevel");
		DataUtil.verify(expect.getSingleCommissionMax(),
				actual.getSingleCommissionMax(), "验证singleCommissionMax");
		DataUtil.verify(expect.getSingleCommissionMin(),
				actual.getSingleCommissionMin(), "验证singleCommissionMin");
		DataUtil.verify(expect.getSingleCommissionRate(),
				actual.getSingleCommissionRate(), "验证singleCommissionRate");
		DataUtil.verify(expect.getCommissionAmount(),
				actual.getCommissionAmount(), "验证commissionAmount");
		/*		DataUtil.verify(expect.getAddTime(), actual.getAddTime(), "验证addTime");
				DataUtil.verify(expect.getUpdateTime(), actual.getUpdateTime(),
						"验证updateTime");*/
		//		DataUtil.verify(expect.getInvoiceId(), actual.getInvoiceId(),
		//				"验证invoiceId");
		DataUtil.verify(expect.getCommissionPerProd(),
				actual.getCommissionPerProd(), "验证commissionPerProd");
		DataUtil.verify(expect.getRealPayAmountPerProd(),
				actual.getRealPayAmountPerProd(), "验证realPayAmountPerProd");
		DataUtil.verify(expect.getRealPayFreight(), actual.getRealPayFreight(),
				"验证realPayFreight");
		DataUtil.verify(expect.getProdNumOfCommission(),
				actual.getProdNumOfCommission(), "验证prodNumOfCommission");
		/*		DataUtil.verify(expect.getInvoiceType(), actual.getInvoiceType(),
						"验证invoiceType");*/

	}

	private void verifyYmtSettlementInvoice(YmtSettlementInvoice expect,
			YmtSettlementInvoice actual) {

		/*	DataUtil.verify(expect.getInvoiceId(), actual.getInvoiceId(),
					"验证invoiceId");*/
		DataUtil.verify(expect.getBusinessNo(), actual.getBusinessNo(),
				"验证businessNo");
		/*		DataUtil.verify(expect.getBusinessType(), actual.getBusinessType(),
						"验证businessType");*/
		DataUtil.verify(expect.getOrderId(), actual.getOrderId(), "验证orderId");
		DataUtil.verify(expect.getTotalAmount(), actual.getTotalAmount(),
				"验证totalAmount");
		DataUtil.verify(expect.getCashAmount(), actual.getCashAmount(),
				"验证cashAmount");
		DataUtil.verify(expect.getGiftAmount(), actual.getGiftAmount(),
				"验证giftAmount");
		DataUtil.verify(expect.getCouponAmount(), actual.getCouponAmount(),
				"验证couponAmount");
		DataUtil.verify(expect.getSellerId(), actual.getSellerId(),
				"验证sellerId");
		/*		DataUtil.verify(expect.getRemark(), actual.getRemark(), "验证remark");
				DataUtil.verify(expect.getAddTime(), actual.getAddTime(), "验证addTime");*/
		/*		DataUtil.verify(expect.getSettlementTime(), actual.getSettlementTime(),
						"验证settlementTime");*/
		/*		DataUtil.verify(expect.getSettlementStatus(),
						actual.getSettlementStatus(), "验证settlementStatus");*/
		DataUtil.verify(expect.getSettlementUser(), actual.getSettlementUser(),
				"验证settlementUser");
		DataUtil.verify(expect.getCommissionAmount(),
				actual.getCommissionAmount(), "验证commissionAmount");
		DataUtil.verify(expect.getProcessResult(), actual.getProcessResult(),
				"验证processResult");
		DataUtil.verify(expect.getfAccountAmount(), actual.getfAccountAmount(),
				"验证fAccountAmount");
		DataUtil.verify(expect.getfThirdPartyAmount(),
				actual.getfThirdPartyAmount(), "验证fThirdPartyAmount");
		/*		DataUtil.verify(expect.getUpdateTime(), actual.getUpdateTime(),
						"验证updateTime");
				DataUtil.verify(expect.getExpectSettleTime(),
						actual.getExpectSettleTime(), "验证expectSettleTime");*/

	}

	/**
	 * 主动请求,生成预估结算单
	 * @param orderId
	 */
	private void callPredictCommission(int orderId) {

		generateinvoicesonorderreceivedBean.setOrderId(orderId);

		predictCommissionCall.setData(generateinvoicesonorderreceivedBean);

		try {

			predictCommissionCall.callService();

			Logger.info(predictCommissionCall.getReturnData());

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PredictCommission_001() {
		Logger.start(true, "使用平台券,商家券。确认收货，校验生成下单结算单，佣金结算单 2种结算单");

		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_PredictCommission_002() {
		Logger.start(true, "含有补贴商品的的订单,确认收货后,校验生成订单结算单,补贴商品结算单,佣金结算 3钟结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			Map map = placeOrder2();
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int orderId = (Integer) map.get("orderId");
			int tradingId = (Integer) map.get("tradingId");
			int sellerId = (Integer) map.get("sellerId");
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			DefaultWapper defaultWapper = new DefaultWapper();
			// 订单商品表
			List<Map> ymtOrderinfoList = defaultWapper
					.selectOrderInfoByOderId(orderId);
			// 补贴结算
			List<Map> subsidySettlementList = defaultWapper
					.selectSubsidySettlementInvoiceByOrderId(orderId);

			BigDecimal orderSubsidyAmount = ymtOrderinfoList.stream()
					.map(m -> (BigDecimal) m.get("fSubsidyAmount"))
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			Logger.comment("校验Ymt_SubsidySettlementInvoice表");
			Logger.verifyEquals(String.valueOf(orderId),
					(String) subsidySettlementList.get(0).get("BusinessNo"),
					"验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) subsidySettlementList.get(0)
					.get("OrderId"), "验证OrderId");
			Logger.verifyEquals(
					orderSubsidyAmount,
					(BigDecimal) subsidySettlementList.get(0).get(
							"SubsidyAmount"), "验证SubsidyAmount");
			Logger.verifyEquals(
					0,
					(Integer) subsidySettlementList.get(0).get(
							"SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(sellerId, (Integer) subsidySettlementList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("订单补贴", (String) subsidySettlementList.get(0)
					.get("Remark"), "验证Remark");
			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_PredictCommission_003() {
		Logger.start(true, "订单里一个商品全款退款,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 退款
			orderCallService.salesRefundSuccessRequestInJava(orderId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_PredictCommission_004() {

		Logger.start(true, "订单里一个商品部分退款,确认收货后,校验生成订单结算单佣金结算单");

		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 申请部分退款
			BigDecimal applyRefundAmout = new BigDecimal(130);

			ApplySalesRefundRequestBean applysalesrefundrequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);
			applysalesrefundrequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(applyRefundAmout);
			ApplySalesRefundRequestCall applysalesrefundrequestCall = new ApplySalesRefundRequestCall();
			applysalesrefundrequestCall.setData(false,
					applysalesrefundrequestBean);
			applysalesrefundrequestCall.callService();

			// 退款处理
			orderCallService
					.salesrefundsuccessrequest(applysalesrefundrequestBean);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_PredictCommission_005() {
		Logger.start(true, "订单里一个商品部分退款,退款数量小于商品购买数量,确认收货后,校验生成订单结算单佣金结算单");
		try {

			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService.placeOrder2(true);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 申请部分退款
			BigDecimal applyRefundAmout = new BigDecimal(130);
			ApplySalesRefundRequestBean applysalesrefundrequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);
			applysalesrefundrequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(applyRefundAmout);
			applysalesrefundrequestBean.getSalesRefundInfoList().get(0)
					.setRefundProductNum(1);
			ApplySalesRefundRequestCall applysalesrefundrequestCall = new ApplySalesRefundRequestCall();
			applysalesrefundrequestCall.setData(false,
					applysalesrefundrequestBean);
			applysalesrefundrequestCall.callService();
			// 退款处理
			orderCallService
					.salesrefundsuccessrequest(applysalesrefundrequestBean);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PredictCommission_006() {
		Logger.start(false, "订单号为空");
		try {
			Logger.comment("前置数据准备结束");
			// generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			generateinvoicesonorderreceivedCall.callService();
			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PredictCommission_007() {

		Logger.start(true, "老买手老客户，使用平台券,商家券。确认收货，校验生成下单结算单,佣金结算，佣金返回 3种结算单");

		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Map map = placeOrder4();

			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);

			OrderCallService orderCallService = new OrderCallService();

			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);

			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(settlemt1, settlemt2, "验证新客单，全部返回佣金");
			Logger.verifyEquals(
					((BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CashAmount"))
							.add((BigDecimal) ymtBackCommissionDetailList
									.get(0).get("CouponAmount")),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(0, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	// @Ignore
	//
	// 手工修改买手审批时间在60天内买手
	// select top 10 dateadd(day,-59,GETDATE()) from ymt_sellerinfo where iuserid=20224977
	// update ymt_sellerinfo set ApproveTime='2016-05-31 19:16:40.337' where iuserid=20224977
	public void Tc_PredictCommission_008() {
		Logger.start(true, "60天内通过审核的新买手，老客户，使用平台券,商家券。"
				+ "确认收货，校验生成下单结算单,佣金结算，佣金返回 3种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Map map = placeOrder3();

			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(settlemt1, settlemt2, "验证新客单，全部返回佣金");
			Logger.verifyEquals(
					((BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CashAmount"))
							.add((BigDecimal) ymtBackCommissionDetailList
									.get(0).get("CouponAmount")),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(0, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	// @Ignore
	//
	// 手工修改买手审批时间在60天内买手
	// select top 10 dateadd(day,-59,GETDATE()) from ymt_sellerinfo where iuserid=20224977
	// update ymt_sellerinfo set ApproveTime='2016-05-31 19:16:40.337' where iuserid=20224977
	public void Tc_PredictCommission_009() {
		Logger.start(true, "60天内通过审核的新买手，新客户，使用平台券,商家券。"
				+ "确认收货，校验生成下单结算单,佣金结算，佣金返回 3种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			Map map = placeOrder7();
			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);
			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			generateinvoicesonorderreceivedBean.setOrderId(orderId);

			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(settlemt1, settlemt2, "验证新客单，全部返回佣金");
			Logger.verifyEquals(
					((BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CashAmount"))
							.add((BigDecimal) ymtBackCommissionDetailList
									.get(0).get("CouponAmount")),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(0, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PredictCommission_010() {
		Logger.start(true, "新客户，老买手，使用平台券,商家券。确认收货，不返还佣金");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			Map map = placeOrder6();
			int userId = (Integer) map.get("userId");
			int sellerId = (Integer) map.get("sellerId");
			JSONArray orderIds = (JSONArray) map.get("orderIds");
			int tradingId = (Integer) map.get("tradingId");
			int orderId = orderIds.getInt(0);

			OrderCallService orderCallService = new OrderCallService();
			// 应付款全金额
			BigDecimal totalPrice = orderCallService
					.getNeedPrePayAmountOfCash(orderId);
			// 支付订单
			orderCallService.orderPayRequest(userId, totalPrice, tradingId);

			YmatouEasyCall payPayMqSenderCall = new YmatouEasyCall("", "POST",
					"JSON");
			String payPayMqSenderString = "{\"orderId\":" + orderId + "}";
			payPayMqSenderCall
					.setUrl("http://operate.trading.iapi.ymatou.com/api/trading/onOrderPaid");
			payPayMqSenderCall.setData(payPayMqSenderString);
			Logger.comment("支付发送消息");
			payPayMqSenderCall.callService();
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Thread.sleep(5000);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

			// 查询交易退款结算表
			List<Map> settlementInvoiceList = new DefaultWapper()
					.selectYmtSettlementInvoice(orderId);

			// 结算佣金
			List<Map> ymtSettlemCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 4)
					.collect(Collectors.toList());
			// 返还佣金
			List<Map> ymtBackCommissionDetailList = settlementInvoiceList
					.stream()
					.filter(commission -> (Integer) commission
							.get("BusinessType") == 6)
					.collect(Collectors.toList());

			BigDecimal settlemt1 = (BigDecimal) ymtSettlemCommissionDetailList
					.get(0).get("TotalAmount");

			BigDecimal settlemt2 = (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("TotalAmount");

			Logger.comment("校验Ymt_SettlementInvoice表，下单确认收货返佣结算");
			Logger.verifyEquals(
					String.valueOf(orderId),
					(String) ymtBackCommissionDetailList.get(0).get(
							"BusinessNo"), "验证BusinessNo");
			Logger.verifyEquals(orderId, (Integer) ymtBackCommissionDetailList
					.get(0).get("OrderId"), "验证OrderId");
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), settlemt2,
					"验证老买手，新客单，不返回佣金");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"TotalAmount"), "验证TotalAmount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtBackCommissionDetailList.get(0).get(
							"CouponAmount"), "验证CouponAmount");
			Logger.verifyEquals(sellerId, (Integer) ymtBackCommissionDetailList
					.get(0).get("SellerId"), "验证SellerId");
			Logger.verifyEquals("返还交易服务费结算",
					(String) ymtBackCommissionDetailList.get(0).get("Remark"),
					"验证Remark");
			Logger.verifyEquals(1, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementStatus"), "验证SettlementStatus");
			Logger.verifyEquals(2, (Integer) ymtBackCommissionDetailList.get(0)
					.get("SettlementUser"), "验证SettlementUser");
			Logger.verifyEquals(
					null,
					(String) ymtBackCommissionDetailList.get(0).get(
							"ProcessResult"), "验证ProcessResult");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fAccountAmount"), "验证fAccountAmount");
			Logger.verifyEquals(null, (BigDecimal) ymtBackCommissionDetailList
					.get(0).get("fThirdPartyAmount"), "验证fThirdPartyAmount");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PredictCommission_011() {

		Logger.start(true, "有运费订单商品，使用平台券,商家券。确认收货，校验生成下单结算单，佣金结算单 2种结算单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Thread.sleep(5000);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

						Logger.verifyEquals("ok",
								generateinvoicesonorderreceivedCall.getReturnData(),
								"验证返回报文");*/

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_PredictCommission_012() {
		Logger.start(true, "有运费订单商品,接单后一个商品部分退款,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);

			// 部分退款
			BigDecimal partRefund = order.getOrderInfoList().get(0)
					.getProductPrice();

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);

			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);
			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(partRefund);

			orderCallService
					.applySalesRefundRequestCall(applySalesRefundRequestBean);
			//退款执行
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			// 确认收货
			orderCallService.confirmReceive(userId, orderId);

			Logger.comment("前置数据准备结束");

			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	@Ignore
	public void Tc_PredictCommission_013() {
		Logger.start(true, "有运费订单商品,接单后一个商品退款加上退部分商品运费,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 部分退款

			OrderInfoPo orderInfoPo1 = order.getOrderInfoList().get(0);

			BigDecimal partRefund = orderInfoPo1.getProductPrice()
					.multiply(new BigDecimal(orderInfoPo1.getAmount()))
					.add(orderInfoPo1.getFreight()).subtract(BigDecimal.ONE);

			ApplySalesRefundRequestBean applySalesRefundRequestBean = orderCallService
					.applySalesRefundRequestInJavaBean(orderId);

			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);
			applySalesRefundRequestBean.getSalesRefundInfoList().remove(1);

			applySalesRefundRequestBean.getSalesRefundInfoList().get(0)
					.setRefundAmount(partRefund);

			orderCallService
					.applySalesRefundRequestCall(applySalesRefundRequestBean);
			//退款执行
			orderCallService
					.salesrefundsuccessrequest(applySalesRefundRequestBean);

			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_PredictCommission_014() {
		Logger.start(true, "有运费订单商品,确认收货后,校验生成订单结算单佣金结算单");
		try {
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = SettlementService
					.placeOrder2(false);

			Order order = placeOrderResp.getOrderList().get(0);

			int orderId = order.getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);
			// 接单
			orderCallService.acceptOrder(orderId, sellerId);
			// 商家发货
			orderCallService.dispatched(orderId, sellerId);
			// 确认收货
			orderCallService.confirmReceive(userId, orderId);
			Logger.comment("前置数据准备结束");
			generateinvoicesonorderreceivedBean.setOrderId(orderId);
			generateinvoicesonorderreceivedCall
					.setData(generateinvoicesonorderreceivedBean);
			/*			generateinvoicesonorderreceivedCall.callService();

			Logger.verifyEquals("ok",
					generateinvoicesonorderreceivedCall.getReturnData(),
					"验证返回报文");*/

			verifyDb();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	/**
	 * 下单使用补贴商品
	 */
	private Map placeOrder2() {
		Map map = new HashMap();
		PlaceOrderReq placeorderBean = new PlaceOrderReq();
		PlaceOrderCall placeorderCall = new PlaceOrderCall();
		try {
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			// 创建产品
			Logger.comment("前置数据准备");
			// 获取补贴商品信息
			HashMap<String, Object> productInfo = new DefaultWapper()
					.selectActivityProductSubsidy();
			int sellerId = (Integer) productInfo.get("SubsidyUserId");
			String productId = (String) productInfo.get("ProductId");
			String catalogId = (String) productInfo.get("CatalogId");
			BigDecimal productPrice = (BigDecimal) productInfo
					.get("ProductPrice");
			int activityId = (Integer) productInfo.get("ActivityId");

			Logger.comment("前置数据准备结束");
			placeorderBean.setAppId("AutoTest");
			// placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(catalogId);
			orderitem1.setProductNum(1);
			orderitem1.setProductName("autotest补贴商品测试");
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setProductId(productId);

			// price = new BigDecimal(210);
			orderitem1.setEarnestPrice(productPrice);
			orderitem1.setProductPrice(productPrice);
			orderitem1.setOriginalPrice(productPrice);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(activityId);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			items.add(orderitem1);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();

			int tradingId = placeorderCall.getTradingId();
			int orderId = placeorderCall.getOrderIds().getInt(0);
			map.put("orderId", orderId);
			map.put("tradingId", tradingId);
			map.put("sellerId", sellerId);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 60天注册新买手，老客户
	 */
	private Map placeOrder3() {

		Map map = new HashMap();

		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 审核在90天内的新买手
			sellerId = 20224977;
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();

			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);

			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);

			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());

			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);
			price = new BigDecimal(30000);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 老买手，老客单 买家在买手 店铺支付完成的第
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder4() {
		Map map = new HashMap();
		try {

			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new UserCallService().registerByMobile();

			int userId = (Integer) newUser.get("userid");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			// sellerId = 20224977;
			Map firstOrder = new HashMap();

			firstOrder = new OrderCallService().createM2cOrder(newUser);

			int orderId = (Integer) firstOrder.get("orderId");
			int tradingId = (Integer) firstOrder.get("tradingId");
			BigDecimal totalPrice = (BigDecimal) firstOrder.get("totalPrice");// 支付金额

			// 支付
			new OrderCallService().orderPayRequest(userId, totalPrice,
					tradingId);
			// 更新订单支付时间
			new DefaultWapper().updateOrderPaidTimeByOrderId(orderId);

			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());

			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");

			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);

			orderitem1.setActivity(null);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(null);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 新买手，老客单
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder5() {
		Map map = new HashMap();
		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new UserCallService().registerByMobile();

			int userId = (Integer) newUser.get("userid");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			// 审核在60天内的新买手
			sellerId = 20224977;
			Map firstOrder = new HashMap();
			firstOrder = new OrderCallService().createM2cOrder(newUser);
			int orderId = (Integer) firstOrder.get("orderId");
			int tradingId = (Integer) firstOrder.get("tradingId");
			BigDecimal totalPrice = (BigDecimal) firstOrder.get("totalPrice");// 支付金额
			// 支付
			new OrderCallService().orderPayRequest(userId, totalPrice,
					tradingId);
			// 更新订单支付时间
			new DefaultWapper().updateOrderPaidTimeByOrderId(orderId);
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 老买手，新用户
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder6() {
		Map map = new HashMap();
		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new UserCallService().registerByMobile();

			int userId = (Integer) newUser.get("userid");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);
			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(22222);
			orderitem2.setThirdCategoryId(33333);
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}

	/**
	 * 一个订单下面多个商品, 新买手，新用户
	 * 
	 * 一单所在日期之后的其他订单（同一买家在该买手店铺支付完成的订单）为该买手的老客订单
	 */
	private Map placeOrder7() {

		Map map = new HashMap();

		try {
			PlaceOrderReq placeorderBean = new PlaceOrderReq();
			PlaceOrderCall placeorderCall = new PlaceOrderCall();
			// 注册新用户
			Map newUser = new HashMap();
			newUser = new UserCallService().registerByMobile();

			int userId = (Integer) newUser.get("userid");
			int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));

			// 审核在90天内的新买手
			sellerId = 20224977;
			Map firstOrder = new HashMap();
			firstOrder = new OrderCallService().createM2cOrder(newUser);
			int orderId = (Integer) firstOrder.get("orderId");
			int tradingId = (Integer) firstOrder.get("tradingId");
			BigDecimal totalPrice = (BigDecimal) firstOrder.get("totalPrice");// 支付金额
			// 创建产品
			Logger.comment("前置数据准备");
			HashMap<String, Object> productInfo = ProductCallService
					.createProduct(sellerId, 3);
			Logger.comment("前置数据准备结束");
			String productId = (String) productInfo.get("productId");
			Logger.debug("productId:" + productId);
			String productName = (String) productInfo.get("productName");
			String pic = (String) productInfo.get("pic");
			BigDecimal price = (BigDecimal) (productInfo.get("price"));
			String catalogId = (String) productInfo.get("catalogId");
			YmatouCouponVo ymtCoupon = new YmatouCouponVo();
			// 平台优惠券
			BigDecimal couponValue = new BigDecimal(13);
			String couponCode = new OrderCallService().receivePlatformCoupon(
					userId, couponValue);
			ymtCoupon.setApplianceType(YmatouCouponApplianceTypeEnum.ALL);
			ymtCoupon.setCouponCode(couponCode);
			ymtCoupon.setCouponValue(couponValue);
			placeorderBean.setAppId("AutoTest");
			placeorderBean.setYmatouCoupon(ymtCoupon);
			placeorderBean.setUserId(userId);
			placeorderBean.setRequestId(TestDataManager.getRandomUUID()
					.toString());
			placeorderBean.setTerminalSource(TerminalSourceEnum.IOS);
			placeorderBean.setAppTerminalSource(AppTerminalSourceEnum.Phone);
			placeorderBean.setSourceIp("127.0.0.1");
			placeorderBean.setAppId("ios");
			placeorderBean.setDeviceId("7777777777888888888888999");
			OrderGroupVo groupVo1 = new OrderGroupVo();
			placeorderBean.setOrderSource(OrderSourceEnum.PC);
			// 商家优惠券
			BigDecimal sellerCouponValue = new BigDecimal(15);
			String sellerCouponCode = new CouponCallService()
					.receiveCouponInfo(sellerId, userId, couponValue);
			SellerCouponVo sellerCoupon = new SellerCouponVo();
			sellerCoupon.setApplianceType(SellerCouponApplianceTypeEnum.ALL);
			sellerCoupon.setCouponCode(sellerCouponCode);
			sellerCoupon.setCouponValue(sellerCouponValue);
			groupVo1.setSellerCoupon(sellerCoupon);
			groupVo1.setSellerId(sellerId);
			List<OrderVo> orders = new ArrayList<OrderVo>();
			OrderVo ordervo1 = new OrderVo();
			ordervo1.setAutoCancelOrderHours(new BigDecimal(1));
			ordervo1.setOrderType(OrderTypeEnum.Spot);
			ordervo1.setPaidFull(true);
			ordervo1.setAddress("上海市闸北区灵石路636号");
			ordervo1.setLeaveWord("ymt autotest");
			ordervo1.setPhone("13100000001");
			ordervo1.setPostCode("200001");
			ordervo1.setTelephone("021-51002100");
			ordervo1.setReceiveName("李四");
			List<OrderItemVo> items = new ArrayList<OrderItemVo>();
			OrderItemVo orderitem1 = new OrderItemVo();
			orderitem1.setCatalogId(TestDataManager.getRandomUUID().toString());
			orderitem1.setProductNum(3);
			orderitem1.setProductName(productName);
			orderitem1.setPriceType(PriceTypeEnum.VipPrice);
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(2);
			orderitem1.setThirdCategoryId(3);
			orderitem1.setProductId(TestDataManager.getRandomUUID().toString());

			price = new BigDecimal(21);
			orderitem1.setEarnestPrice(price);
			orderitem1.setProductPrice(price);
			orderitem1.setOriginalPrice(price);
			orderitem1.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem1.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1.setBrandId(5);
			orderitem1.setPackageNo("11111111");
			orderitem1.setFirstCategoryId(1149);
			orderitem1.setSecondCategoryId(22222);
			orderitem1.setThirdCategoryId(33333);
			orderitem1
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem1.setProductRecordNo("1234567");
			orderitem1
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem1
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			ActivityVo activity = new ActivityVo();
			activity.setActivityId(46870);
			activity.setActivityBeginDate(YMTDateUtil.getBeforeOrNextDay(-10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityEndDate(YMTDateUtil.getBeforeOrNextDay(10,
					"yyyy-MM-dd'T'HH:mm:ss"));
			activity.setActivityTemplateId(12345678);
			activity.setCommissionRate(new BigDecimal(1.1));
			activity.setCost(true);
			activity.setFeeFree(false);
			activity.setPremium(new BigDecimal(1.5));
			activity.setPromotionPrice(new BigDecimal(15));
			activity.setPromotionType(ActivityPromotionTypeEnum.DiscountRate);
			activity.setUseCoupon(true);
			orderitem1.setActivity(activity);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			// 第2件商品
			OrderItemVo orderitem2 = new OrderItemVo();
			orderitem2.setCatalogId("edbcc2c9-1ba9-4b04-ab88-940f63271823");
			orderitem2.setProductNum(1);
			orderitem2.setProductName(productName);
			orderitem2.setPriceType(PriceTypeEnum.VipPrice);
			orderitem2.setProductId(TestDataManager.getRandomUUID().toString());
			orderitem2.setFirstCategoryId(1149);
			orderitem2.setSecondCategoryId(2);
			orderitem2.setThirdCategoryId(3);

			price = new BigDecimal(30);
			orderitem2.setEarnestPrice(price);
			orderitem2.setProductPrice(price);
			orderitem2.setOriginalPrice(price);
			orderitem2.setSalesType(SalesTypeEnum.AlreadyInStock);
			orderitem2.setLogisticsType(LogisticsTypeEnum.SailProtect);
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2.setBrandId(5);
			orderitem2.setPackageNo("11111111");
			orderitem2
					.setProductDetailInfo("e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男");
			orderitem2.setProductRecordNo("1234567");
			orderitem2
					.setProductRefundChannel(ProductRefundChannelEnum.Official);
			orderitem2
					.setProperty("06f25e0c-e431-44ae-8a07-4d0bc824e3bd#尺寸:951a814e-2ded-4241-b9a0-91b2cd9a44fd#6,d2f663ea-3214-4344-abce-a8eaffcc43ce#颜色:f3ed3ad7-a084-450b-b698-256542963306#红色");
			orderitem2.setActivity(activity);
			items.add(orderitem1);
			items.add(orderitem2);
			ordervo1.setOrderItems(items);
			ordervo1.setFreight(new BigDecimal("21"));
			orders.add(ordervo1);
			groupVo1.setOrders(orders);
			placeorderBean.setOrderGroups(Arrays.asList(groupVo1));
			placeorderCall.setData(false, placeorderBean);
			placeorderCall.callService();
			JSONArray orderIds = placeorderCall.getOrderIds();
			int tradingId2 = placeorderCall.getTradingId();
			map.put("userId", userId);
			map.put("sellerId", sellerId);
			map.put("orderIds", orderIds);
			map.put("tradingId", tradingId2);
		} catch (Exception e) {
			Logger.fail(e);
		}
		return map;
	}
}
